﻿using Microsoft.Extensions.Configuration;
using System.Data;

namespace MiniFox.Data.Configurations
{
    /// <summary>
    /// 
    /// </summary>
    public class CommandConfiguration 
    {
        const string NAME = "name";
        const string CONNECTION = "connectionName";
        const string TEXT = "text";
        const string TYPE = "commandType";
        const string PREPARE = "prepare";
        const string PARAMETERS = "parameters";
        const string TIMEOUT = "timeout";

        /// <summary>
        /// 
        /// </summary>
        public CommandConfiguration()
        {
            this.Prepare = false;
            this.CommandType = CommandType.Text;
            this.TimeOut = 60;
        }

        /// <summary>
        /// 名称
        /// </summary>
        [ConfigurationKeyName(NAME)]
        public string Name
        {
            get;
            set;
        }
        /// <summary>
        /// 连接名
        /// </summary>
        [ConfigurationKeyName(CONNECTION)]
        public string ConnectionName
        {
            get;
            set;
        }
        /// <summary>
        /// 命令文本
        /// </summary>
        [ConfigurationKeyName(TEXT)]
        public string Text
        {
            get;
            set;
        }
        /// <summary>
        /// 是否预处理命令(注：预处理命令将强制要求参数指定size)
        /// </summary>
        [ConfigurationKeyName(PREPARE)]
        public bool Prepare
        {
            get;
            set;
        }

        /// <summary>
        /// 命令类型
        /// </summary>
        [ConfigurationKeyName(TYPE)]
        public CommandType CommandType
        {
            get;
            set;
        }

        /// <summary>
        /// 超时时长(单位：秒)
        /// </summary>
        [ConfigurationKeyName(TIMEOUT)]
        public int TimeOut
        {
            get;
            set;
        }

        /// <summary>
        /// 命令参数配置集
        /// </summary>    
        [ConfigurationKeyName(PARAMETERS)]
        public ParameterSettingCollection ParameterSettings
        {
            get;
            set;
        }

    }

}
